<?php


//引入头文件
header('Content-type:image/png');

//创建画布
$src = imagecreatetruecolor(200,50);

//设置背景颜色
$color = imagecolorallocate($src,195, 195, 195);

//填充颜色
imagefill($src,0,0,$color);


//画线条
for($i=0;$i<20;$i++){
	$col = imagecolorallocate($src,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
    imageline($src,mt_rand(0,200),mt_rand(0,25),mt_rand(25,200),mt_rand(25,50),$col);
}

//打雪花
for($j=0;$j<500;$j++){
	$col = imagecolorallocate($src,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
	imagesetpixel($src,mt_rand(0,200), mt_rand(0,50), $col);
}

//随机验证码
for($k=0;$k<4;$k++){
	$txt = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789';
	$code = $txt[mt_rand(0,strlen($txt)-1)];	
	$width = 30*$k;
	$width += 30;
	$height=mt_rand(30,40);
	$height += 5;
	$col = imagecolorallocate($src,mt_rand(0,155),mt_rand(0,155),mt_rand(0,155));
	imagettftext ( $src,30, mt_rand(-10,10),$width,$height,$col,'./FireBlock.ttf',$code);
}



//输出图像
imagepng($src);


//释放资源
imagedestroy($src);








































